/**
 * 
 */
package org.wangh.db.datatype;

import java.util.Locale;

/**
 * @author wang
 *
 */
public abstract class AbstractDataType {
	
	protected final String name;
	
	protected final String sqlType;
	
	protected final String attribute;
	
	protected AbstractDataType(String name, String sqlType, String attribute){
		this.name = toUpperCase(name);
		this.sqlType = toUpperCase(sqlType);
		this.attribute = toUpperCase(attribute);
	}

	public String getName() {
		return name;
	}

	public String getSqlType() {
		return sqlType;
	}

	public String getAttribute() {
		return attribute == null ? "" : attribute;
	}
	
	public String getDescription(){
		if(attribute == null){
			return name + " " + sqlType;
		}
		else{
			return name + " " + sqlType + " " + attribute;
		}
	}
	
	protected String toUpperCase(String string){
		return string == null ? null : string.toLowerCase(Locale.ENGLISH);
	}
	
}
